import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test {
    public static void main(String[] args) {
        String htmlString = "<p style=\"text-align: justify;\"><br><img src=\"https://example.com/image1.jpg\" alt=\"Image 1\"><br><img src=\"https://example.com/image2.jpg\" alt=\"Image 2\"></p>";

        // 定义正则表达式来匹配 img 标签中的 src 属性
        String imgRegex = "<img[^>]+src=\"([^\"]+)\"";
        Pattern pattern = Pattern.compile(imgRegex);
        Matcher matcher = pattern.matcher(htmlString);

        if (matcher.find()) {
            // 提取第一个匹配的 src 属性值
            String imageUrl = matcher.group(1);
            System.out.println("The first image URL is: " + imageUrl);
        } else {
            System.out.println("No image URL found.");
        }
    }
}
